package com.hk.employeemanagementsystem.util.web;

import java.util.HashMap;
import java.util.Map;

/**
 * @author by 何坤
 * @Classname WebCode
 * @Description TODO
 * @Date 2019/11/7 20:58
 */
public final class WebCode {
    public static final String MSG = "msg";
    public static final String SUCCESS = "success";
    public static final String FAILED = "failed";
    public static final String SUCCESS_SAVE = "保存成功。";
    public static final String SUCCESS_SELECT = "查询成功。";
    public static final String FAILURE_SELECT = "查询失败。";
    public static final String FAILURE_SAVE = "保存失败。";
    public static final String SUCCESS_UPDATE = "更新成功。";
    public static final String FAILURE_UPDATE = "更新失败。";
    public static final String SUCCESS_DELETE = "删除成功。";
    public static final String FAILURE_DELETE = "删除失败。";
    public static final String DELETE_SUBNODE_FIRST = "请先删除子节点。";
    public static final String SUCCESS_RENAME = "重命名成功。";
    public static final String FAILURE_RENAME = "重命名失败。";
    public static final String SUCCESS_OPERATE = "操作成功。";
    public static final String FAILURE_OPERATE = "操作失败。";
    public static final String SUCCESS_COPY = "复制成功。";
    public static final String FAILURE_COPY = "复制失败。";
    public static final String SUCCESS_NEW = "升级成功。";
    public static final String FAILURE_NEW = "升级失败。";
    public static final String SUCCESS_SEND = "发送成功。";
    public static final String FAILURE_SEND = "发送失败。";
    public static final String SUCCESS_MARK = "标记成功。";
    public static final String FAILURE_MARK = "标记失败。";
    public static final String SUCCESS_RECOVERY = "恢复成功。";
    public static final String FAILURE_RECOVERY = "恢复失败。";
    public static final String SUCCESS_ADD_BLT = "加入黑名单成功。";
    public static final String FAILURE_ADD_BLT = "加入黑名单失败。";
    public static final String SUCCESS_SAVE_DRAFT = "已存入草稿。";
    public static final String FAILURE_SAVE_DRAFT = "存入草稿失败。";
    public static final String NOTIFY_CONFIG_ID = "SYS_DEFAULT_CONFIG";
    public static final String SUCCESS_ENABLE = "启用成功";
    public static final String FAILURE_ENABLE = "启用失败";
    public static final String SUCCESS_DISABLE = "停用成功";
    public static final String FAILURE_DISABLE = "停用失败";
    public static final String OUT_OF_DATE = "OUT_OF_DATE";
    public static final String SAVE_DATA_EXIST = "保存的数据已经存在";
    public static final String LOGIN_VALIDATE = "loginValidate";
    public static final String FAILURE_OUT_OF_DATE = "在你编辑本条数据的过程中，本条数据已被别人编辑并保存过了。";
    public static final String BIZ_MODEL_NOT_DEL = "该业务模块菜单被业务流程使用，不能删除";
    public static final String DEFAULT_LAYOUT = "default";
    public static final String PARAM_TENANT_REQUIRED = "tenantRequired";
    public static final String SUCCESS_START_PROCESS = "流程启动成功";
    public static final String FAILURE_START_PROCESS = "流程启动失败";
    public static final String SUCCESS_DEPLOY = "部署成功";
    public static final String FAILURE_DEPLOY = "部署失败";
    public static final String SUCCESS_UNDEPLOY = "反部署成功";
    public static final String FAILURE_UNDEPLOY = "反部署失败";
    public static final String SUCCESS_PUSH = "推送成功";
    public static final String FAILURE_PUSH = "推送失败";

    public WebCode() {
    }

    public static Map<String, Object> successOperation() {
        return success("操作成功。");
    }

    public static Map<String, Object> failureOperation() {
        return failure("操作失败。");
    }

    public static Map<String, Object> failureOperation(String msg) {
        return failure("操作失败。:" + msg);
    }

    public static Map<String, Object> success(String msg) {
        Map<String, Object> result = wrap("msg", msg);
        result.put("success", true);
        return result;
    }

    public static Map<String, Object> failure(String msg) {
        Map<String, Object> result = wrap("msg", msg);
        result.put("success", false);
        return result;
    }

    private static Map<String, Object> wrap(String key, Object value) {
        Map<String, Object> map = new HashMap();
        map.put(key, value);
        return map;
    }
}
